package com.taobao.home.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.taobao.home.model.po.Store;
import com.taobao.home.model.po.StorePreview;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 商品Mapper接口
 */
public interface StoreMapper extends BaseMapper<Store> {

    /**
     * 关注页店铺预览
     */
    @Select("SELECT store_id, store_name, store_icon, remark, title, label, release_time, img_list, buy_num, look_num FROM stores WHERE 1 =1 LIMIT #{pageNo}, #{pageSize}")
    List<StorePreview> queryPreview(@Param("pageNo") Long pageNo, @Param("pageSize") Long pageSize);

    /**
     * 根据店铺id查询店铺信息
     */
    @Select("SELECT * from stores WHERE store_id = #{storeId}")
    Store queryStoreById(@Param("storeId") Integer storeId);

    /**
     * 根据店铺id查询我的店铺
     */
    @Select("SELECT * from stores WHERE owner_id = #{userId}")
    List<Store> queryMyStore(@Param("userId") int userId);

    /**
     * 根据店铺id删除店铺
     */
    @Delete("DELETE FROM stores WHERE store_id = #{storeId}")
    int deleteStoreById(@Param("storeId") Integer storeId);
}
